#include <WiFi.h>

const char *ssid = "A618";
const char *password = "123321xx.";

const char *host = "192.168.3.209";
const uint16_t port = 8080;

void setup()
{
  Serial.begin(115200);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }

  Serial.println("Connected to WiFi");
}

void loop()
{
  WiFiClient client;

  if (!client.connect(host, port))
  {
    Serial.println("Connection to host failed");
    delay(1000);
    return;
  }

  // String message = "Hello from ESP32";
  // client.print(message);
  String response = client.readStringUntil('\n');
  Serial.println("Received from server: " + response);

  Serial.println("Message sent");
  client.stop();

  delay(5000);
}